package com.mjf

import org.apache.flink.api.scala._

object Test2 {
  def main(args: Array[String]): Unit = {

    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)

    val input: DataSet[String] = env.fromElements(
      "hello world",
      "hello world",
      "hello world"
    )

    val result: AggregateDataSet[(String, Int)] = input
      .flatMap(_.split(" "))
      .map {
        word =>
          println("---------------map--------------")
          (word, 1)
      }
      .groupBy(0)
      .sum(1)

    println("-----------------------------------")

    result.print()

  }
}
